//
//  shuffle.c
//  Testat_5
//
//  Created by Benno Lauther on 20.11.13.
//
//

#include <stdio.h>
#include "shuffle.h"
#include <time.h>
#include <stdlib.h>

void shuffleArray(int (*cardStack)[NR_CARDS])
{
    /** shuffle cards - Knuth-Fisher-Yates shuffle **/
    int j;
    int k;
    srand((unsigned int)time(NULL));  /* start random number generater */
    for (int i = NR_CARDS -1; i; i--) {
        j = rand() % (i + 1);  /* random variable modulo remaining cards */
        /* swap entries of fields i and j */
        k = (*cardStack)[i];
        (*cardStack)[i] = (*cardStack)[j];
        (*cardStack)[j] = k;
    }
}